package interpreter.bytecodes;

import interpreter.VirtualMachine;
import java.util.Vector;

/**
 *
 * @author Kristofer Selbekk
 */
public class GoToByteCode extends ByteCode {
    private int address;
    private String id;

    /**
     * Initializes the goto byte code with 1 argument
     */
    public void init( Vector<String> args ) {
        id = args.get(0);
    }

    /**
     * Action: Go to label with resolved address <em>address</em>.
     *
     * @param rt the Virtual Machine reference
     */
    public void exec( VirtualMachine rt ) {
        rt.setPC(address);
    }

    public int getAddress() {
        return address;
    }
    public void setAddress( int addr ) {
        address = addr;
    }

    public Object getArgs() {
        return id;
    }

    public String toString() {
        return super.toString() + " " + address;
    }
}
